package com.shopmall.product.controller;

import com.shopmall.model.entity.product.Category;
import com.shopmall.model.vo.common.Result;
import com.shopmall.model.vo.common.ResultCodeEnum;
import com.shopmall.product.service.CategoryService;
import com.shopmall.product.service.Impl.CategoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/product/category")
//@CrossOrigin
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    // 查询所有分类，树形封装
    @GetMapping("/findCategoryTree")
    public Result<List<Category>> findCategoryTree() {
        List<Category> list = categoryService.findCategoryTree();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }
}
